Skip to content

Openmemory cleanup#135

Closed
AnkushMalaker wants to merge 3 commits intomainfrom
openmemory-cleanup
Closed

Openmemory cleanup#135
AnkushMalaker wants to merge 3 commits intomainfrom
openmemory-cleanup

Conversation

@AnkushMalaker
Copy link
Collaborator

@AnkushMalaker AnkushMalaker commented Oct 21, 2025

Summary by CodeRabbit

  • Documentation

    • Updated service startup references and added official Docker image note.
  • Improvements

    • Simplified OpenMemory MCP initialization process with improved environment variable handling.
    • Switched to official Docker image for enhanced reliability and consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

The OpenMemory MCP service integration transitions from local Docker builds and complex setup scripting to using a published Docker image. The initialization flow shifts from setup.sh to run.sh, with API key and environment variable handling refactored in both the startup script and wizard orchestration.

Changes

Cohort / File(s) Change Summary
Documentation
Docs/init-system.md
Updated Service Scripts documentation to reference extras/openmemory-mcp/run.sh instead of setup.sh and added note about using the official Docker image.
OpenMemory MCP Configuration
extras/openmemory-mcp/docker-compose.yml
Switched from local build (build context + Dockerfile) to published official image (mem0/openmemory-mcp:latest); updated accompanying comments.
OpenMemory MCP Build/Cache Management
extras/openmemory-mcp/.gitignore
Removed cache/ from ignore rules to stop tracking local cache directory.
OpenMemory MCP Scripts
extras/openmemory-mcp/init-cache.sh, extras/openmemory-mcp/setup.sh
Removed both scripts; eliminated local cache initialization (git clone/checkout) and comprehensive setup logic (file ops, CLI parsing, interactive prompts).
OpenMemory MCP Runtime
extras/openmemory-mcp/run.sh
Enhanced with .env loading/creation from template, OPENAI_API_KEY environment propagation into .env file, and improved user guidance for missing credentials.
Service Orchestration
wizard.py
Updated startup command from setup.sh to run.sh; added dedicated service check for run.sh existence; refactored OPENAI_API_KEY handling from CLI argument injection to environment variable propagation via env_vars dict.

Sequence Diagram

sequenceDiagram
    participant User
    participant wizard.py
    participant run.sh
    participant docker-compose
    participant Image as mem0/openmemory-mcp:latest

    User->>wizard.py: Invoke startup for openmemory-mcp<br/>(with OPENAI_API_KEY env var)
    wizard.py->>wizard.py: Verify run.sh exists
    wizard.py->>run.sh: Execute with env_vars<br/>(OPENAI_API_KEY)
    run.sh->>run.sh: Load or create .env<br/>from template
    run.sh->>run.sh: Propagate OPENAI_API_KEY<br/>into .env file
    run.sh->>docker-compose: Invoke docker-compose up
    docker-compose->>Image: Pull & run mem0/openmemory-mcp:latest
    Image-->>docker-compose: Container running
    docker-compose-->>User: Service ready
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Multiple interconnected changes across scripts, configuration, and orchestration—script removal/replacement, environment variable propagation refactoring, and Docker image migration—but all focused on a single service's startup flow with coherent patterns.

Possibly related PRs

  • Better init system #74: Both PRs modify the OpenMemory MCP setup/start flow and touch the same extras/openmemory-mcp scripts (setup.sh / run.sh) and docker-compose configuration.
  • Feat/local omi scripts #129: Both PRs modify wizard.py's service setup logic (service-existence checks and run_service_setup function), including startup script handling and environment variable propagation.
  • Fix/wizard nits #134: Both PRs modify wizard.py and address environment-based credential handling for OPENAI_API_KEY propagation to service startup.

Suggested reviewers

  • thestumonkey

Poem

🐰 Hop-hop! The scripts take flight,
Old setup gives way to official light,
From local build to image so bright,
run.sh guides the way through the night,
Keys flow through env—all working right! 🔑✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "Openmemory cleanup" is related to the changeset in that most modifications occur in the openmemory-mcp directory, but it is vague and generic. The term "cleanup" lacks specificity about what is being cleaned up, whereas the actual changes represent a substantive refactoring: migrating from local build scripts and setup procedures to using an official Docker image (mem0/openmemory-mcp:latest), removing init-cache.sh and setup.sh, and updating configuration handling in run.sh. A teammate scanning history would not clearly understand the primary architectural change from the title alone, as "cleanup" fails to convey the shift to official image-based deployment. Consider refining the title to explicitly communicate the main change, such as "Switch openmemory-mcp to use official Docker image" or "Migrate openmemory-mcp from local build to official image deployment." This would provide clarity about the structural shift and help reviewers and future maintainers understand the intent without reading the full changeset details.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch openmemory-cleanup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AnkushMalaker
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
extras/openmemory-mcp/docker-compose.yml (1)

13-13: Consider pinning to a specific image version.

Using the :latest tag can lead to non-reproducible deployments and unexpected breaking changes when the upstream image updates. Consider pinning to a specific version tag for stability.

Example:

-    image: mem0/openmemory-mcp:latest
+    image: mem0/openmemory-mcp:v1.0.0

Alternatively, document the decision to use :latest if auto-updates are intentional.

wizard.py (1)

226-232: Remove unused variable assignment.

The result variable on line 226 is assigned but never used. Since the return code is already checked via exception handling, this assignment can be removed.

Apply this diff:

-        result = subprocess.run(
+        subprocess.run(
             cmd,
             cwd=service['path'],
             check=True,
             timeout=300,  # 5 minute timeout for service setup
             env=env_vars
         )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d407036 and a2c2511.

📒 Files selected for processing (7)
  • Docs/init-system.md (1 hunks)
  • extras/openmemory-mcp/.gitignore (0 hunks)
  • extras/openmemory-mcp/docker-compose.yml (1 hunks)
  • extras/openmemory-mcp/init-cache.sh (0 hunks)
  • extras/openmemory-mcp/run.sh (1 hunks)
  • extras/openmemory-mcp/setup.sh (0 hunks)
  • wizard.py (5 hunks)
💤 Files with no reviewable changes (3)
  • extras/openmemory-mcp/init-cache.sh
  • extras/openmemory-mcp/setup.sh
  • extras/openmemory-mcp/.gitignore
🧰 Additional context used
🪛 Ruff (0.14.1)
wizard.py

226-226: Local variable result is assigned to but never used

Remove assignment to unused variable result

(F841)


226-226: subprocess call: check for execution of untrusted input

(S603)

🪛 Shellcheck (0.11.0)
extras/openmemory-mcp/run.sh

[warning] 14-14: Quote this to prevent word splitting.

(SC2046)

🔇 Additional comments (7)
Docs/init-system.md (1)

33-33: LGTM!

The documentation accurately reflects the migration from setup.sh to run.sh and correctly notes the use of the official Docker image.

extras/openmemory-mcp/run.sh (2)

23-34: Verify sed -i portability across platforms.

Line 28 uses sed -i for in-place file editing, which behaves differently on macOS (requires sed -i '') versus Linux. This could cause the script to fail on macOS systems.

Consider using a portable approach:

-        sed -i "s|^OPENAI_API_KEY=.*|OPENAI_API_KEY=${OPENAI_API_KEY}|" .env
+        sed -i.bak "s|^OPENAI_API_KEY=.*|OPENAI_API_KEY=${OPENAI_API_KEY}|" .env && rm .env.bak

Or detect the platform:

if [[ "$OSTYPE" == "darwin"* ]]; then
    sed -i '' "s|^OPENAI_API_KEY=.*|OPENAI_API_KEY=${OPENAI_API_KEY}|" .env
else
    sed -i "s|^OPENAI_API_KEY=.*|OPENAI_API_KEY=${OPENAI_API_KEY}|" .env
fi

Can you verify if this script is expected to run on macOS?


36-43: LGTM!

The updated error messaging clearly guides users through the three options for providing the OPENAI_API_KEY, aligning well with the new .env-based workflow.

wizard.py (4)

7-7: LGTM!

The os import is correctly added to support the new environment variable handling for openmemory-mcp.


75-79: LGTM!

The command correctly updated from setup.sh to run.sh, aligning with the PR's migration of the startup script.


94-98: LGTM!

The dedicated branch correctly verifies the presence of run.sh for the openmemory-mcp service, maintaining consistency with the startup script migration.


208-216: LGTM!

The migration from CLI arguments to environment variables for OPENAI_API_KEY is correct and aligns with the updated run.sh script's expectation to receive the key via environment variables.

Comment on lines +11 to +21
# Check for .env file first, load if exists
if [ -f .env ]; then
echo "📝 Loading configuration from .env file..."
export $(cat .env | grep -v '^#' | xargs)
else
# Create .env from template if it doesn't exist
if [ -f .env.template ]; then
echo "📝 Creating .env from template..."
cp .env.template .env
fi
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix potential word-splitting issue in environment variable loading.

Line 14 uses an unquoted command substitution that can cause word-splitting issues. While this pattern works in many cases, it can fail with values containing spaces or special characters.

Apply this diff for a safer approach:

-    export $(cat .env | grep -v '^#' | xargs)
+    set -a
+    source .env
+    set +a

Or if you need to preserve the existing behavior:

-    export $(cat .env | grep -v '^#' | xargs)
+    export "$(cat .env | grep -v '^#' | xargs)"

The set -a; source .env; set +a approach is more robust and handles complex values correctly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Check for .env file first, load if exists
if [ -f .env ]; then
echo "📝 Loading configuration from .env file..."
export $(cat .env | grep -v '^#' | xargs)
else
# Create .env from template if it doesn't exist
if [ -f .env.template ]; then
echo "📝 Creating .env from template..."
cp .env.template .env
fi
fi
# Check for .env file first, load if exists
if [ -f .env ]; then
echo "📝 Loading configuration from .env file..."
set -a
source .env
set +a
else
# Create .env from template if it doesn't exist
if [ -f .env.template ]; then
echo "📝 Creating .env from template..."
cp .env.template .env
fi
fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 14-14: Quote this to prevent word splitting.

(SC2046)

🤖 Prompt for AI Agents
In extras/openmemory-mcp/run.sh around lines 11 to 21, the script uses unquoted
command substitution and xargs to export environment variables from .env which
can cause word-splitting and break values with spaces or special characters;
replace that section to load .env robustly by using the shell's source mechanism
with automatic export: enable export with set -a, source the .env file (skipping
comments), then disable automatic export with set +a — this preserves complex
values and is safer than parsing with xargs.

@AnkushMalaker AnkushMalaker deleted the openmemory-cleanup branch December 18, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant